using System;
using System.Collections.Generic;
using System.Text;
using emp.OracleDAL;
using System.Data;

namespace emp.BLL
{
    public class MatchBrandBLL
    {
        MatchBrand g_var = MatchBrand.ini();        

        public bool fillTargetBrandTable(int p_id,string type)
        {
            bool ReturnValue = true;
            //first step clear the target table
            g_var.clearTargetBrandTable(p_id);

            //second step fill the target table which is from audi's website db

            DataTable dt = g_var.getWebSiteCarBrandInfo(type);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (g_var.insertTargetBrandTable(dt.Rows[i][0].ToString(), dt.Rows[i][1].ToString(), p_id) == 0)
                {
                    ReturnValue = false;
                    break; 
                }              
            }

            return ReturnValue;
        }

        public int matchWithWebSiteDataBLL(int parentid, int childid,string matchtype)
        {
            return g_var.matchWithWebSiteData(parentid, childid, matchtype);
        }
    }
}
